package per.dg.tencent.fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import java.util.ArrayList;
import java.util.List;

import per.dg.tencent.R;
import per.dg.tencent.adapter.BannerViewPagerAdapter;
import per.dg.tencent.adapter.HomeFragmentAdapter;
import per.dg.tencent.databinding.FragmentHomeBinding;

public class HomeFragment extends Fragment {

    Context mContext;

    FragmentHomeBinding mFragmentHomeBinding;

    List<View> mViewList;

    public static HomeFragment newInstance() {
        return new HomeFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {

        mContext = getContext();

        mFragmentHomeBinding = FragmentHomeBinding.inflate(inflater);

        List<String> list = new ArrayList<>();
        for(int i = 0; i < 7; i++){
            list.add("");
        }
        mFragmentHomeBinding.appVpBanner.setAdapter(new BannerViewPagerAdapter(mContext, list));

        mViewList = new ArrayList<>();

        View inflate = LayoutInflater.from(mContext).inflate(R.layout.item_home_fragment, mFragmentHomeBinding.appVpHome, true);

        mViewList.add(inflate.findViewById(R.id.app_line_home_jingxuan));
        mViewList.add(inflate.findViewById(R.id.app_line_home_aikan));

        List<String> mStringList = new ArrayList<>();
        for(int i = 0; i < 2; i++){
            mStringList.add("ddd");
        }
//        mFragmentHomeBinding.appVpHome.setAdapter(new HomeFragmentAdapter(inflate, mStringList));
        mFragmentHomeBinding.appVpHome.setAdapter(new HomeFragmentAdapter(mViewList));

        return mFragmentHomeBinding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

}